package top.oylan.manager.controller.admin;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import top.oylan.manager.entity.User;
import top.oylan.manager.service.UserService;
import top.oylan.manager.tools.Pager;

import javax.annotation.Resource;

/**
 * Created by A on 2019/2/12.
 */
@Controller
@RequestMapping("/admin/user")
public class AdminUserController {

    @Resource
    UserService userService;

    @RequestMapping(value = {"/list","","/"})
    public String index(ModelMap modelMap, @RequestParam(value = "page",defaultValue = "1")Integer page){

        Pager<User> pager = new Pager<User>();
        User condition = new User();
        condition.setType((byte)2);

        pager.setCondition(condition);
        pager.setCurrentPage(page);

        pager.setList(userService.selectManagerByPager(pager));

        modelMap.addAttribute("pager",pager);
        return "admin/user/list";
    }
}
